/*
 * Group 3, User Interface Programming II (vt11)
 * Pooya | Flora | Monica | Can
 */
package vical.view;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.border.Border;
import vical.model.Internationalization;
import java.awt.event.KeyEvent;

/**
 * The Dialog to display some information of this application and our team
 * 
 * @author Can
 */
public class AboutDialog extends JDialog {

    private JPanel applicationInfoPanel;
    private JPanel teamInfoPanel;
    private JPanel contactInfoPanel;
    private Border padding;
    private JTabbedPane tabbedPane;
    String applicationInfoDesc = "Application Informaiton:";
    String teamInfoDesc = "Team Information";
    String contactInfoDesc = "Contact Information";

    public AboutDialog() {
        System.out.println("Inside constructor");
        initComponents();
    }

    public void initComponents() {

        System.out.println("Inside initComponents");
        applicationInfoPanel = showApplicationInfo();
        teamInfoPanel = showTeamInfo();
        contactInfoPanel = showContactInfo();

        padding = BorderFactory.createEmptyBorder(20, 20, 5, 20);
        applicationInfoPanel.setBorder(padding);
        teamInfoPanel.setBorder(padding);
        contactInfoPanel.setBorder(padding);
        tabbedPane = new JTabbedPane();
        tabbedPane.addTab(Internationalization.getString("about_tab_application"), null,
                applicationInfoPanel,
                applicationInfoDesc); //tooltip text
        tabbedPane.addTab(Internationalization.getString("about_tab_team"), null,
                teamInfoPanel,
                teamInfoDesc); //tooltip text
        tabbedPane.addTab(Internationalization.getString("about_tab_contact"), null,
                contactInfoPanel,
                contactInfoDesc); //tooltip text
        this.setTitle("About Dialog");

        this.add(tabbedPane, BorderLayout.CENTER);
        this.setSize(450, 250);
        this.setLocationRelativeTo(null);
        this.setModal(true);

    }

    private JPanel showApplicationInfo() {
        JPanel pane = new JPanel(new BorderLayout());
        JPanel okButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
        JTextArea addText = new JTextArea(5, 40);
        String applicationDetails = Internationalization.getString("about_application_info");
        addText.append(applicationDetails);
        JButton okButton = new JButton(Internationalization.getString("about_ok_button"));
        okButton.setMnemonic(KeyEvent.VK_O);
        okButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setVisible(false);
            }
        });
        addText.setEditable(false);
        okButtonPanel.add(okButton);
        pane.add(addText, BorderLayout.CENTER);
        pane.add(okButtonPanel, BorderLayout.SOUTH);

        return pane;
    }

    private JPanel showTeamInfo() {
        JPanel pane1 = new JPanel(new BorderLayout());
        JPanel okButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
        JTextArea addText = new JTextArea(7, 40);
        String teamDetails = Internationalization.getString("about_team_info");
        addText.append(teamDetails);
        JButton okButton = new JButton(Internationalization.getString("about_ok_button"));
         okButton.setMnemonic(KeyEvent.VK_O);
        okButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setVisible(false);
            }
        });
        addText.setEditable(false);
        okButtonPanel.add(okButton);
        pane1.add(addText, BorderLayout.CENTER);
        pane1.add(okButtonPanel, BorderLayout.SOUTH);

        return pane1;
    }

    private JPanel showContactInfo() {
        JPanel pane2 = new JPanel(new BorderLayout());
        JPanel okButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
        JTextArea addText = new JTextArea(7, 40);
        String contactDetails = Internationalization.getString("about_contact_info");
        addText.append(contactDetails);
        JButton okButton = new JButton(Internationalization.getString("about_ok_button"));
         okButton.setMnemonic(KeyEvent.VK_O);
        okButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setVisible(false);
            }
        });
        addText.setEditable(false);
        okButtonPanel.add(okButton);
        pane2.add(addText, BorderLayout.CENTER);
        pane2.add(okButtonPanel, BorderLayout.SOUTH);

        return pane2;
    }
}
